<?php

namespace App\Services\Admin;



use App\Http\Models\Admin\File\File;
use App\Http\Models\Admin\Sys\SysParam;
use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Mail;

class AdService
{

     public function getEmailConfig(){
         $find = SysParam::where('name',Config::get('common.system_email_tag',"system_email_tag"))->first();
         $value = null;
         if($find){
//             var_dump(unserialize($find->value));
             return unserialize($find->value);
         }
         return null;
     }
     public function sendMail($template,$target){


         $config = $this->getEmailConfig();
         if($config){
            Config::set("mail.from.address",$config['email']);
            Config::set("mail.from.name",$config['name']);
         }

         Mail::queue($template, [], function($message) use ($target)
         {
             $message->to($target['email'], $target['name']);
         });
     }


}
